//
//  CAnAlgSwimSumData.m
//  sr01sdkProject
//
//  Created by  on 2024/9/3.
//

#import "CAnAlgSwimSumData.h"

@implementation CAnAlgSwimSumData

-(NSNumber *)dataTimeStamp
{
    return @(self.timeStamp);
}

- (instancetype)initWithData:(NSData *)data
{
    self = [super init];
    if (self) {
        
        if (data.length < 20) {
            return self;
        }
        
        uint8_t *dataBytes = (uint8_t *)[data bytes];
        _cmdByte = dataBytes[1];
        // 四字节时间戳
        uint32_t timeStamp = *((uint32_t *)(dataBytes + 2));
        _timeStamp = timeStamp;
        _totalStrokes = *((uint16_t *)(dataBytes + 6));
        _swimDuration = *((uint16_t *)(dataBytes + 8));
        _totalSwimmingDistance = *((uint16_t *)(dataBytes + 10));// 总游泳距离
        
        _pace = *((uint16_t *)(dataBytes + 12));//dataBytes[12];//平均配速
        
        _swimmingLaps = dataBytes[14];//游泳圈数
        
        _swolf = *((uint16_t *)(dataBytes + 15));// 平均游泳效率
    }
    return self;
}
@end
